package com.itheima.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealCheckGroupMapper {
    /**
     * 插入套餐和检查组关联数据
     * @param setmealId
     * @param checkgroupIds
     */
    void insert(Integer setmealId, Integer[] checkgroupIds);

    /**
     * 根据套餐id删除关系数据
     * @param id
     */
    @Delete("delete from setmeal_check_group where setmeal_id = #{id}")
    void deleteBySetmealId(Integer id);

    /**
     * 根据套餐id查询关系数据
     * @param id
     * @return
     */
    @Select("select check_group_id from setmeal_check_group where setmeal_id = #{id}")
    List<Integer> selectBySetmealId(Integer id);

    /**
     * 查询检查组id是否存在
     * @param id
     * @return
     */
    @Select("select count(1) from setmeal_check_group where check_group_id = #{id}")
    Integer hasCheckGroupId(Integer id);
}
